<template>
	<div class="app-container">
		<el-card class="box-card" >
		  <div slot="header" class="clearfix">
			<span>内容</span>
		  </div>
		 <ckeditor    v-model="purpose" :config="editorConfig0"></ckeditor>
		</el-card>
		<row style="margin-top: 30px;" v-if="advancedStatus=='0'">
			<el-col :span="18" style="margin-top: 30px;">
				<el-input v-model="examineComments1" placeholder="请输入审核意见" />
			</el-col>
			<el-col :span="6" style="margin-top: 30px;">
				<el-button
				  type="primary"
				  @click="submitForm('1')"
				>审核拒绝</el-button>
				<el-button
					  type="primary"
					  @click="submitForm('2')"
				>审核通过</el-button>
			</el-col>	 
		</row>
		
	</div>
	  
  
</template>

<script>
import { listMeterial, getMeterial, delMeterial, addMeterial, updateMeterial, exportMeterial } from "@/api/eqxm/meterial";
import { applyAdvanced,getTeamStudent,updateTeamStudent,examine } from "@/api/eqxm/teamStudent";
import { listMidmeterial } from "@/api/eqxm/midmeterial";
import CommonUtils from "@/utils/CommonUtils";
import CKEditor from 'ckeditor4-vue';
export default {
  name: "Meterial",
  components: {
    ckeditor: CKEditor.component
  },
  data() {
    return {
      // 遮罩层
      loading: true,
	  cardshow:true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 材料上传表格数据
      meterialList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        teamid: null,
        purpose: null,
        midid: null,
        summary: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      teamid:"",
      activeName:'1',
      editorConfig0:{},
      purpose:'',
      id:'',
	  time:'',
	  teamStudentId:"",
	  examineComments1:"",
	  advancedStatus:"0"
    };
  },
  created() {
    this.teamStudentId = this.$route.params && this.$route.params.teamStudentId;
    this.getList();
  },
  methods: {
    /** 查询材料上传列表 */
    getList() {
      getTeamStudent(this.teamStudentId).then(response => {
        this.purpose = response.data.purpose;
		this.examineComments1=response.data.purpose;
		this.advancedStatus=response.data.advancedStatus;
      });
      
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        teamid: null,
        purpose: null,
        midid: null,
        summary: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加材料上传";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getMeterial(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改材料上传";
      });
    },
    /** 提交按钮 */
    submitForm(res) {
      let subForm={};
	  subForm.advancedStatus=res;
	  subForm.examineComments1=this.examineComments1;
	  subForm.id=this.teamStudentId;
      examine(subForm).then(response => {
        this.$modal.msgSuccess("审核成功");
		
      });

    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除材料上传编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delMeterial(ids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有材料上传数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportMeterial(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    },
    handleClick(tab, event) {
		 this.time=""
		 this.purpose=""
      this.getList()
     
    }
  }
};
</script>
